#!/bin/bash

#nome dos nos
Nomes=("frontend" "node1" "node2" "node3" "node4" "node5" "node6" "node18" "node8" "node17" "node10" "node11" "node12" "node15" "node16")

ssh ${Nomes[0]} "./nivel4 7401 7402 > saida0.txt" &
sleep 1
ssh ${Nomes[1]} "./nivel3 ${Nomes[0]} 7403 7404 7401 > saida1.txt" &
ssh ${Nomes[2]} "./nivel3 ${Nomes[0]} 7405 7406 7402 > saida2.txt" &
sleep 1
ssh ${Nomes[3]} "./nivel2 ${Nomes[1]} 7407 7408 7403 > saida3.txt" & 
ssh ${Nomes[4]} "./nivel2 ${Nomes[1]} 7409 7410 7404 > saida4.txt" &
ssh ${Nomes[5]} "./nivel2 ${Nomes[2]} 7411 7412 7405 > saida5.txt" &
ssh ${Nomes[6]} "./nivel2 ${Nomes[2]} 7413 7414 7406 > saida6.txt" &
sleep 1
ssh ${Nomes[7]} "./nivel1 ${Nomes[3]} 7407 > saida7.txt" &
ssh ${Nomes[8]} "./nivel1 ${Nomes[3]} 7408 > saida8.txt" &
ssh ${Nomes[9]} "./nivel1 ${Nomes[4]} 7409 > saida9.txt" &
ssh ${Nomes[10]} "./nivel1 ${Nomes[4]} 7410 > saida10.txt" &
ssh ${Nomes[11]} "./nivel1 ${Nomes[5]} 7411 > saida11.txt" &
ssh ${Nomes[12]} "./nivel1 ${Nomes[5]} 7412 > saida12.txt" &
ssh ${Nomes[13]} "./nivel1 ${Nomes[6]} 7413 > saida13.txt" &
ssh ${Nomes[14]} "./nivel1 ${Nomes[6]} 7414 > saida14.txt"
